﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.models {
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.world.vos.*;
    import __AS3__.vec.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;

    public class ContractsModel extends Actor {

        private var _contracts:Vector.<ContractOfferVO>;
        private var _currentContract:ContractVO;
        private var _state:String;

        public static const CREATING:String = "CREATING";
        public static const WAITING:String = "WAITING";
        public static const DELIVER_GOODS:String = "DELIVER_GOODS";
        public static const READY_TO_FINALIZE:String = "READY_TO_FINALIZE";
        public static const READY_TO_CREATE:String = "READY_TO_CREATE";

        public function ContractsModel(){
            this._contracts = new Vector.<ContractOfferVO>();
            super();
        }
        public function addContract(_arg1:ContractOfferVO):void{
            this._contracts.push(_arg1);
        }
        public function getContractOfferById(_arg1:String):ContractOfferVO{
            var _local2:ContractOfferVO;
            for each (_local2 in this._contracts) {
                if (_local2.code == _arg1){
                    return (_local2);
                };
            };
            return (null);
        }
        public function get contracts():Vector.<ContractOfferVO>{
            return (this._contracts);
        }
        public function get currentContract():ContractVO{
            return (this._currentContract);
        }
        public function set currentContract(_arg1:ContractVO):void{
            this._currentContract = _arg1;
        }
        public function get state():String{
            return (this._state);
        }
        public function set state(_arg1:String):void{
            this._state = _arg1;
            if (_arg1 == READY_TO_CREATE){
                this._currentContract = null;
            };
            dispatch(new InfoEvent(EventConstants.UPDATED_CONTRACT, this._state));
        }

    }
}//package net.wooga.pets.models 
